from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# 1.打开Chrome
driver = webdriver.Chrome()
# 2.输入百度网址
time.sleep(2)
driver.get('http://www.so.com')
# 3.获取搜索框输入关键字-天气预报
time.sleep(2)
ip = driver.find_element(By.ID, 'input')
ip.send_keys('天气预报')
# 4.获取搜索按钮
time.sleep(2)
bu = driver.find_element(By.ID, 'search-button')
# 点击方法
bu.click()
# 获取页面标题并打印出来
time.sleep(2)
print(driver.title)
# 检查'python'关键字是否在标题中
if 'python' in driver.title:
    print('ok')
else:
    print('no')
# 关闭Chrome浏览器
time.sleep(2)
driver.quit()